var { ReturnModel } = require('../libs/resmodel');
var { peoplefanFollow, peoplefanTakeoff, peoplefanMyfans, peoplefanMyfollow,peopleUninterested } = require('../services/peoplefan');
var { peoplecontactSave, peoplecontactForMy } = require('../services/peoplecontact');

/**
* 收藏
* @api {post} /peoplefan/follow 收藏
* @apiDescription 收藏
* @apiName follow
* @apiParam (参数) {String} pcode 被收藏用户code
* @apiParam (参数) {String} fcode 粉丝用户code
* @apiSampleRequest /peoplefan/follow
* @apiGroup peoplefan-粉丝/收藏
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "pcode": "290464549598", 
*       "fcode": "249485919615"
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "收藏成功",
*      "code": 0
*   }
*/
async function follow(req, res) {
    let result = await peoplefanFollow(req.body);
    res.json(new ReturnModel(result));
}
/**
* 取消收藏
* @api {post} /peoplefan/takeoff 取消收藏
* @apiDescription 取消收藏
* @apiName takeoff
* @apiParam (参数) {String} pcode 被收藏用户code
* @apiParam (参数) {String} fcode 粉丝用户code
* @apiSampleRequest /peoplefan/takeoff
* @apiGroup peoplefan-粉丝/收藏
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*       "pcode": "290464549598", 
*       "fcode": "249485919615"
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "取消收藏成功",
*      "code": 0
*   }
*/
async function takeoff(req, res) {
    let result = await peoplefanTakeoff(req.body);
    res.json(new ReturnModel(result));
}
/**
* 联系推荐人
* @api {post} /peoplefan/contactSave 联系推荐人
* @apiDescription 点击联系推荐人时，调用此接口，保存联系人状态
* @apiName contactSave
* @apiParam (参数) {String} pcode 被联系用户code
* @apiParam (参数) {String} fcode 联系用户code（粉丝）
* @apiSampleRequest /peoplefan/contactSave
* @apiGroup peoplefan-粉丝/收藏
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
 *     {
 *         "pcode": "138359400020",
 *         "fcode": "833631688190",
 *     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "success",
*      "code": 0
*   }
*/
async function contactSave(req, res) {
    let result = await peoplecontactSave(req.body);
    res.json(new ReturnModel(result));
}
/**
* 收藏我的
* @api {post} /peoplefan/myfans 收藏我的
* @apiDescription 收藏我的
* @apiName myfans
* @apiParam (参数) {String} pcode 用户code
* @apiSampleRequest /peoplefan/myfans
* @apiGroup peoplefan-粉丝/收藏
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*        "pcode": "290464549598"
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "data": [{
*       "code": "290464549598", //当前访问记录用户code，点击时用此code进入用户主页
*       "info": {nickname:'xx', avator:'xxx',age:29, grender:'男',birthday:'1999/10/23',star:'天蝎座',height:175,signature:'个性签名',education:'硕士'}, // 用户信息
*       "updatetime": "2022-04-02 15:23", // 关注时间
*       "state": 1, //  关注状态，1：关注我(可回关)，2：互相关注
*       }],
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function myfans(req, res) {
    let result = await peoplefanMyfans(req.body);
    res.json(new ReturnModel(result));
}
/**
* 我的收藏
* @api {post} /peoplefan/myfollow 我的收藏
* @apiDescription 我的收藏
* @apiName myfollow
* @apiParam (参数) {String} pcode 用户code
* @apiSampleRequest /peoplefan/myfollow
* @apiGroup peoplefan-粉丝/收藏
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
*     {
*        "pcode": "290464549598"
*     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "data": [{
*       "code": "290464549598", //当前访问记录用户code，点击时用此code进入用户主页
*       "info": {nickname:'xx', avator:'xxx',age:29, grender:'男',birthday:'1999/10/23',star:'天蝎座',height:175,signature:'个性签名',education:'硕士'}, // 用户信息
*       "updatetime": "2022-04-02 15:23", // 关注时间
*       "state": 1, //  关注状态，1：我关注，2：互相关注
*       }],
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function myfollow(req, res) {
    let result = await peoplefanMyfollow(req.body);
    res.json(new ReturnModel(result));
}
/**
* 我的联系人
* @api {post} /peoplefan/contactForMy 我的联系人
* @apiDescription 消息里我的联系人接口
* @apiName contactForMy
* @apiParam (参数) {String} pcode 用户code
* @apiSampleRequest /peoplefan/contactForMy
* @apiGroup peoplefan-粉丝/收藏
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
 *     {
 *         "pcode": "138359400020"
 *     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "data": [{   
*       "code": "290464549598", //当前访问记录用户code，点击时用此code进入用户主页
*       "info": {nickname:'xx', avator:'xxx',age:29, grender:'男',birthday:'1999/10/23',star:'天蝎座',height:175,signature:'个性签名',education:'硕士'}, // 用户信息
*       "createtime": "2022-04-02 15:23", // 关注时间
*       }],
*      "msg": "获取成功",
*      "code": 0
*   }
*/
async function contactForMy(req, res) {
    let result = await peoplecontactForMy(req.body);
    res.json(new ReturnModel(result));
}
/**
* 不感兴趣
* @api {post} /peoplefan/uninterested 不感兴趣
* @apiDescription 不感兴趣，点击后不会再推送此用户(例如：A对B不感兴趣)
* @apiName uninterested
* @apiParam (参数) {String} pcode 不感兴趣用户code（B用户）
* @apiParam (参数) {String} fcode 我的code（A用户）
* @apiSampleRequest /peoplefan/uninterested
* @apiGroup peoplefan-不感兴趣
* @apiVersion 1.0.0
* @apiParamExample {json} Request-Example:
 *     {
 *         "pcode": "138359400020"
 *         "fcode": "302210109605"
 *     }
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*   {
*      "msg": "操作成功，系统不会再推荐此用户给您",
*      "code": 0
*   }
*/
async function uninterested(req, res) {
    let result = await peopleUninterested(req.body);
    res.json(new ReturnModel(result));
}

module.exports = function (app) {
    let base_url = '/api/peoplefan';

    app.post(base_url+'/follow', follow);
    app.post(base_url+'/takeoff', takeoff);
    app.post(base_url+'/myfans', myfans);
    app.post(base_url+'/myfollow', myfollow);
    app.post(base_url+'/contactSave', contactSave);
    app.post(base_url+'/contactForMy', contactForMy);
    app.post(base_url+'/uninterested', uninterested);
}
